home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / COSEmulator / COSEmulator- SRC / src / NewWindowWindow.cpp < prev    next >
Encoding:
Text File  |  1998-06-21  |  4.9 KB  |  202 lines  |  [TEXT/CWIE]

  1. //===================================================================
  2. //=======================  Headers        =============================
  3.  
  4. #include "NewWindowWindow.h"
  5. #include "GameUtilities.h"
  6. #include "Screen.h"
  7. #include "ApplicationHandler.h"
  8. #include "ApplicationEvents.h"
  9.  
  10. //===================================================================
  11. //=======================  Globals        =============================
  12.  
  13.  
  14. //===================================================================
  15. //=======================  #define        =============================
  16.  
  17.  
  18. //===================================================================
  19. //=======================  Function Prototypes    =====================
  20.  
  21.  
  22. /*----------------------------------------------------------------------------\
  23.  
  24.     NewWindowWindow :: Constructor
  25.  
  26. \----------------------------------------------------------------------------*/
  27.     NewWindowWindow :: NewWindowWindow( void )
  28.                     : Window()
  29. {
  30.     okDown = false;
  31.     MySetRectWH( &okButton , 347 , 38 , 68 , 28 );
  32. }
  33.  
  34.  
  35. /*----------------------------------------------------------------------------\
  36.  
  37.     NewWindowWindow :: Init
  38.  
  39. \----------------------------------------------------------------------------*/
  40. Boolean    NewWindowWindow :: Init( void )
  41. {
  42.     width = 433;
  43.     height = 350;
  44.     if( window.NewBuff( width , height ) )
  45.     {
  46.         OffScreenBuff    backGround;
  47.         
  48.         backGround.LoadPicBuff( 142 );
  49.         
  50.         DrawPicture( &backGround , &backGround.GetBoundsSize(), 
  51.                      &window , &window.GetBoundsSize() );
  52.         
  53.         screenLoc.left = 200;
  54.         screenLoc.top = 200;
  55.         screenLoc.right = screenLoc.left + width;
  56.         screenLoc.bottom = screenLoc.top + height;
  57.         
  58.         return true;
  59.     }
  60.     
  61.     return false;
  62. }
  63.  
  64. /*----------------------------------------------------------------------------\
  65.  
  66.     NewWindowWindow :: HandleMouseClick
  67.  
  68. \----------------------------------------------------------------------------*/
  69. void    NewWindowWindow :: HandleMouseClick( Boolean down , point where )
  70. {
  71.     if( down )
  72.     {
  73.         draging = true;
  74.         start = where;
  75.         
  76.         where.x -= screenLoc.left;
  77.         where.y -= screenLoc.left;
  78.         
  79.         if( SectPtRect( where , okButton ) )
  80.         {
  81.             OffScreenBuff    buttonDown;
  82.             rect            blarg;
  83.             
  84.             buttonDown.LoadPicBuff( 143 );
  85.             DrawPicture( &buttonDown , &buttonDown.GetBoundsSize(), 
  86.                          &window , &okButton );
  87.             
  88.             blarg.left = screenLoc.left + okButton.left;
  89.             blarg.right = screenLoc.left + okButton.right; 
  90.             blarg.top = screenLoc.top + okButton.top; 
  91.             blarg.bottom = screenLoc.top + okButton.bottom; 
  92.             
  93.             screen.AddRectToUpdate( blarg );
  94.             // draw it down
  95.             okDown = true;
  96.         }
  97.     }
  98.     else
  99.     {
  100.         if( okDown )
  101.         {
  102.             AH.SendEventToCurrentApp( kAEProgramSpec , NULL );
  103.         }
  104.         
  105.         if( draging )
  106.         {
  107.             screen.AddRectToUpdate( screenLoc );
  108.             
  109.             MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
  110.  
  111.             screen.AddRectToUpdate( screenLoc );
  112.             
  113.             draging = false;
  114.         }
  115.     }
  116. }
  117.  
  118. /*----------------------------------------------------------------------------\
  119.  
  120.     NewWindowWindow :: HandleMouseMove
  121.  
  122. \----------------------------------------------------------------------------*/
  123. void    NewWindowWindow :: HandleMouseMove( point where )
  124. {
  125.     if( draging )
  126.     {
  127.         screen.AddRectToUpdate( screenLoc );
  128.         
  129.         MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
  130.         start = where;
  131.         
  132.         screen.AddRectToUpdate( screenLoc );
  133.     }
  134. }
  135.  
  136. /*----------------------------------------------------------------------------\
  137.  
  138.     NewWindowWindow :: PointInWindow
  139.  
  140. - just saids if the point it inside the window area or not
  141. \----------------------------------------------------------------------------*/
  142. Boolean    NewWindowWindow :: PointInWindow( point where )
  143. {
  144.     return SectPtRect( where , screenLoc );
  145. }
  146.  
  147. /*----------------------------------------------------------------------------\
  148.  
  149.     NewWindowWindow :: Active
  150.  
  151. \----------------------------------------------------------------------------*/
  152. Boolean    NewWindowWindow :: Front( void )
  153. {
  154.     return( front );
  155. }
  156.  
  157. /*----------------------------------------------------------------------------\
  158.  
  159.     NewWindowWindow :: SetFront
  160.  
  161. \----------------------------------------------------------------------------*/
  162. void    NewWindowWindow :: SetFront( Boolean f )
  163. {
  164.     if( f != front )
  165.     {
  166.         front = f;
  167.         screen.AddRectToUpdate( screenLoc );
  168.     }
  169. }
  170.  
  171. /*----------------------------------------------------------------------------\
  172.  
  173.     NewWindowWindow :: DrawToScreen
  174.  
  175. \----------------------------------------------------------------------------*/
  176. void    NewWindowWindow :: DrawToScreen( rect *where , Boolean backGround )
  177. {
  178.     if( front && !backGround )
  179.     {
  180.         if( where == NULL )
  181.         {
  182.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  183.                         NULL , 0 , 0 , 0 );
  184.         }
  185.         else
  186.         {
  187.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  188.                         where , 0 , 0 , 0 );
  189.         }
  190.     }
  191.     else
  192.     {
  193.         if( where == NULL )
  194.         {
  195.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  196.                         NULL , kDrawTint , 16 , 0xffff );
  197.         }
  198.         else
  199.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  200.                         where , kDrawTint , 16 , 0xffff );
  201.     }
  202. }